package com.jindu.producer.finance.jpa;

import com.jindu.producer.finance.model.FRecommendEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author jarvischang
 */
@Transactional
public interface RecommendJpa extends JpaRepository<FRecommendEntity,Long>,JpaSpecificationExecutor {

    /**
     * 根据id 查询 单个实体
     * @param id
     * @return
     */
    FRecommendEntity findById(String id);


    /**
     * 根据类型
     * @param type
     * @return
     */
    List<FRecommendEntity> findByType(Integer type);


    /**
     * 根据id删除数据
     * @param id
     * @return
     */
    @Modifying
    @Query("delete from FRecommendEntity where id = ?1 ")
    int deleteById(String id);


}
